﻿using System;
using System.Linq;
using System.Text;
using System.Windows;
using System.Collections.Generic;

using Cratos.Desktop;
using Cratos.Tools.General;
using Cratos.Generator.DataObject;

namespace Cratos.Generator
{
	/// <summary>
	/// Project Presenter class
	/// </summary>
	public class ProjectPresenter : MVPCrudPresenter<ProjectView>
	{
		#region Class Constant declarations
		#endregion

		#region Class Event declarations
		#endregion

		#region Class Variable declarations
		private ApplicationPresenter		m_AppPresenter;
		private CratosProjectPresenter	m_ProjectPresenter;
		#endregion

		#region Class Constructors & Destructors
		/// <summary>
		/// Class Constructor
		/// </summary>
		public ProjectPresenter(ApplicationPresenter appPresenter, ProjectView currentView) : base(currentView, "Project")
		{
			// Save the relevant values
			this.m_AppPresenter		= appPresenter;
			currentView.Presenter	= this;

			// Create the relevant objects
			this.m_ProjectPresenter                 = new CratosProjectPresenter(appPresenter, currentView.m_ProjectView);
			this.m_ProjectPresenter.ProgressStart  += new MVPProgressEvent(this.OnProgressStart);
			this.m_ProjectPresenter.ProgressUpdate += new MVPProgressUpdateEvent(this.OnProgressUpdate);
			this.m_ProjectPresenter.ProgressEnd    += new MVPProgressEvent(this.OnProgressEnd);

			// Set the relevant CRUD options
			this.CanCreate = this.Project.CanCreate;
			this.CanModify = this.Project.CanUpdate;
			this.CanDelete = this.Project.CanDelete;
		}
		#endregion

		#region Class Properties
		/// <summary>
		/// Current Project
		/// </summary>
		public DOCratosProject Project
		{
			get { return (this.m_ProjectPresenter.Project); }
			set { this.m_ProjectPresenter.Project = value; this.OnNotifyPropertyChanged("Project"); }
		}

		/// <summary>
		/// Application Presenter
		/// </summary>
		public ApplicationPresenter ApplicationPresenter
		{
			get { return (this.m_AppPresenter); }
		}
		#endregion

		#region Class Methods
		/// <summary>
		/// Create New
		/// </summary>
		public void Create()
		{
			// Declare the required variables

			//// Create the new Region
			//this.Project          = new DOCratosProject();
			//this.Project.Date			= DateTime.Now;
			//this.Project.DOAction = DOCratosAction.Create;
			//this.OnNotifyPropertyChanged("Project");

			//// Update the relevant indicators
			//this.IsInEdit = true;

			// Set the focus
			//this.View.m_TxtProjectName.Focus();

			// Return to calling method
			return;
		}

		/// <summary>
		/// Load the Project
		/// </summary>
		/// <param name="projectID">Project ID</param>
		public void LoadProject(long projectID)
		{
			// Declare the required variables

			// Load the relevant Project
			this.m_ProjectPresenter.LoadProject(projectID);

			// Return to calling method
			return;
		}

		/// <summary>
		/// Close the Tab
		/// </summary>
		public void Close()
		{
			// Declare the required variables

			// Close the Tab
			this.ApplicationPresenter.CloseTab(this);

			// Return to calling method
			return;
		}
		#endregion

		#region Class Support Methods
		#endregion
	}
}
